package com.common.www.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class RemoteDBUtils {
    //这里可以设置数据库名称

    private Connection conn = null;

    public RemoteDBUtils(String URL, String USER, String PASSWORD) {
        try {
            //1.加载驱动程序
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Properties properties = new Properties();

            //2.获得数据库的连接
            conn = (Connection) DriverManager.getConnection(URL, USER, PASSWORD);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    //对外提供一个方法来获取数据库连接
    public Connection getConnection() {
        return conn;
    }


}
